<!DOCTYPE html>
<!--<html -->
<!--        xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"-->
<!--      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">-->
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
</head>
<body>
<a href='/evaluate/pj'>站点评价</a></dd>
<div>
    <span class="layui-input-inline">查询条件：</span>
    <form class="layui-form-pane" action="/evaluate/search">
        <!--            分数-->
        <input type="text" name="evaluateStar" id="evaluateStar" oninput = "value=value.replace(/[^\d]/g,'')" class="layui-input-block" autocomplete="off" placeholder="请输入查询分数(0-5)" >&nbsp;&nbsp;
        <button class="layui-btn layui-btn-small"  lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i></button>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </form>
</div>
<div class="x-nav">
    <!--    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">-->
    <!--        <i class="layui-icon" style="line-height:30px">ဂ</i></a>-->
</div>
<table class="layui-table">
    <thead>
    <tr>
        <th hidden="hidden">评价ID</th>
        <th >用户</th>
        <th >评价星级</th>
        <th>评价时间</th>
        <th>评价内容</th>
        <th>状态</th>
        <th>操作</th>
    </thead>
    <tbody>

    <tr th:each="x:${list}">
        <!--        <td>-->
        <!--            <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>-->
        <!--        </td>-->
        <td hidden="hidden" th:text="${x.evaluateId}"></td>
        <td th:text="${x.user.userName}"></td>
        <td th:text="${x.evaluateStar}"></td>
        <td th:text="${x.evaluateTime}"></td>
        <td th:text="${x.evaluateContent}"></td>
        <td class="td-status" th:if="${x.evaluateStatus==1}">
            <span class="layui-btn layui-btn-normal layui-btn-mini">显示</span>
        </td>
        <td class="td-status" th:if="${x.evaluateStatus==0}">
            <span class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled">隐藏</span>
        </td>

        <td class="td-manage" th:if="${x.evaluateStatus==1}">
            <a onclick="member_stop(this,'10001')" href="javascript:;" title="显示">
                <i class="layui-icon">&#xe601;</i>
            </a>
        </td>
        <td class="td-manage" th:if="${x.evaluateStatus==0}">
            <a onclick="member_stop(this,'10001')" href="javascript:;"  title="隐藏">
                <i class="layui-icon">&#xe601;</i>
            </a>
        </td>
    </tr>
    </tbody>
</table>
<div class="page">
    <div>
        <a class="prev" th:href="@{/evaluate/allPageList(page=${prePage})}">&lt;&lt;</a>
        <a class="num" href="/evaluate/allPageList">首页</a>
        <span class="current" th:text="${curPage}"></span>
        <a class="num" th:href="@{/evaluate/allPageList(page=${totalPages})}">尾页</a>
        <a class="next" th:href="@{/evaluate/allPageList(page=${nextPage})}">&gt;&gt;</a>
    </div>
</div>
</div>
</body>
</html>
<script>function member_stop(obj,id){
    //用户停用启用
    //更改按钮样式

    layer.confirm('确认要更改状态吗？',function(index){
        var evaluateId =$(obj).parents("tr").find("td").eq(0).text();
        if($(obj).attr('title')=='显示'){
            //发异步把用户状态进行更改
            $.ajax({
                url: "/evaluate/show",
                async: false,
                type: "POST",
                dataType: "json",
                data: {
                    "evaluateId":evaluateId,
                    "evaluateStatus":0
                },
                success: function (data) {
                    //放入了map中，调用info
                    if (data==true) {
                        $(obj).attr('title','隐藏')
                        $(obj).find('i').html('&#xe62f;');
                        $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('隐藏');
                        layer.msg('已隐藏!',{icon: 5,time:1000});
                    }else {
                        layer.msg('隐藏失败!',{icon: 1,time:1000});
                    }
                }
            })

        }else {
            $.ajax({
                url: "/evaluate/show",
                async: false,
                type: "POST",
                dataType: "json",
                data: {
                    "evaluateId": evaluateId,
                    "evaluateStatus": 1
                },
                success: function (data) {
                    //放入了map中，调用info
                    if (data==true) {
                        $(obj).attr('title', '显示')
                        $(obj).find('i').html('&#xe601;');
                        $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('显示');
                        layer.msg('已显示!', {icon: 6, time: 1000});
                    } else {
                        layer.msg('显示失败!', {icon: 1, time: 1000});
                    }
                }
            });
        }
    })
}</script>
